﻿using System.Linq;
using Actya.Core.SiteStructure;
using Raven.Abstractions.Indexing;
using Raven.Client.Indexes;

namespace Actya.Core.IndexDefinitions
{
	public class Pages_BySearchTerm : AbstractIndexCreationTask<Page>
	{
		public Pages_BySearchTerm()
		{
			this.Map = pages => from page in pages
			               select new {page.Title, page.Url, page.Content};

			Index(x => x.Title, FieldIndexing.Analyzed);
			Index(x => x.Url, FieldIndexing.NotAnalyzed);
			Index(x => x.Content, FieldIndexing.Analyzed);

			Store(x => x.Title, FieldStorage.Yes);
			Store(x => x.Url, FieldStorage.Yes);
		}
	}
}